package org.luxor.commons.workflow.enums;

import org.activiti.engine.ActivitiIllegalArgumentException;

/**
 * 驳回类型定义
 *
 * @author Mr.yan  @date 2022/8/2
 */
public enum RejectType {

    StartUser(0, "提单节点"),
    PrevActivity(1, "上一步"),
    PrevAssignee(2, "上个办理人"),
    AnyActivity(3, "任意节点"),
    ProcessEnd(4, "终止流程");

    private final Integer code;
    private final String explain;

    RejectType(Integer code, String explain) {
        this.code = code;
        this.explain = explain;
    }

    public Integer code() {
        return code;
    }

    public String explain() {
        return explain;
    }

    public static RejectType codeOf(Integer code) {
        for (RejectType rejectType : values()) {
            if (rejectType.code.equals(code)) {
                return rejectType;
            }
        }
        throw new ActivitiIllegalArgumentException("驳回类型代码不合法");
    }

}
